package jpb.module.dao.apply;

import jpb.module.dao.apply.mapper.ApplyMapper;
import jpb.module.daomain.apply.Apply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by haol on 2017/5/7.
 */
@Repository
public class ApplyDao {

        @Autowired
        private ApplyMapper mapper;

        private Logger logger = LoggerFactory.getLogger(ApplyDao.class);

        public List<Apply> getApplyByOidAndStateIsZero(String oid) {
                try {
                       return mapper.getApplyByOidAndStateIsZero(oid);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public void add(Apply apply) {
                try {
                        mapper.add(apply);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }

        public List<Apply> getApplyByOid(String oid) {
                try {
                       return mapper.getApplyByOid(oid);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public Apply getById(Integer id) {
                try {
                        return mapper.get(id);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public List<Apply> getByNum(String num){
                try {
                        return mapper.getByNum(num);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }

        }
        public List<Apply> getByOidAndState(String oid,int state,String num){
                try {
                        return mapper.getByOidAndState(oid,state,num);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }

        }
        public void update(Apply apply){
                try {
                        mapper.update(apply);
                } catch (Exception e) {
                        logger.error(e.getMessage());

                }

        }
        public void delete(Integer id){
                try {
                        mapper.delete(id);
                } catch (Exception e) {
                        logger.error(e.getMessage());

                }
        }

}
